{extend name="$base" /}
{block name="alert_info"}
<p class="function-prompts">建议您在更新前，备份相关的程序及数据信息，以免更新失败给您造成不必要的损失。</p>
{/block}
{block name="resources"}
<style>
.prompt_information{color: orange;padding-left: 10px;margin:12px;border-left:3px solid orange;}
.back-color {
	border-radius: 14px;
    display: inherit;
    color: #ffffff;
    overflow:hidden;
    padding: 3px 9px;
}
.color_0{background: #9E9E9E;}
.color_1{background: darkcyan;}
.color_2{background: goldenrod;}
.color_3{background: darkcyan;}
.table-class a{background: #4F85F1;border-radius:5px;color: #ffffff;padding: 5px;}
.text-left {text-align: left; padding-left: 20px;}
.table-class tr td{font-size: 12px;}
.table-class tr th:FIRST-CHILD,.table-class tr td:FIRST-CHILD{padding-left: 20px;}
.mod-table{padding: 0 10px}
</style>
{/block}
{block name="main"}

<input type="hidden" id="upgrade_typeid" />
<div class="prompt_information" id="warning_info" >
</div>
<div class="mod-table">
	<table class="table-class">
		<colgroup>
			<col style="width: 15%;">
			<col style="width: 15%;">
			<col style="width: 15%;">
			<col style="width: 10%">
		</colgroup>
		<thead>
			<tr>
				<th>更新包版本</th>
				<th>更新包编号</th>
				<th>发布时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody id="linkList"></tbody>
	</table>
</div>
<div class="modal fade hide" id="up_patch" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h3>在线升级</h3>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style" style="height:70px;">
					<table class="modal-tab">
						<tr>
							<td style="width:70%">是否备份数据库</td>
							<td >
								<input id="is_backup" type="checkbox" class="checkbox"/>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<div class="modal-footer">
				<input type="hidden" id="modify_username_hidden" />
				<button class="btn-common" onclick="upPatch()" id="butSubmit">升级</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
	
	<input type="hidden" id="p_type" value="0"/>
	<input type="hidden" id="p_release" value="0"/>
	<input type="hidden" id="patch_list"/>
</div>
<div id="back_patch" style="background:#f5f5f5;display:none;margin:auto;z-index:10;height:100%;width:100%">
	<div style="height:200px;width:200px;background:#000;opacity: 0.65;text-align:center;margin: auto;">
		<span>正在备份</span>
	</div>
</div>
<form action="{:__URL('ADMIN_MAIN/upgrade/upgradePatch')}" method="post" id="fpForm">
	<input type="hidden" id="patch_obj" name="upgradePatch_detail"/>
</form>
{/block}
{block name="script"}
<script type="text/javascript">

//分页数据
function LoadingInfo() {
	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/version/getUpgradeVersion')}",
		data : {},
		success : function(data) {
			if(data){
				if (data["data"].length > 0) {
					$(".table-class tbody").empty();
					for (var i = data["data"].length - 1; i >= 0; i--) {
						var html = '';
						html += '<tr align="center">';

						
						html += '<td><span class="back-color color_1">V'+data["data"][i]["version_name"]+' </span></td>';
						html += '<td><span class="back-color color_2">'+data["data"][i]["version_release"]+' </span></td>';
						
						if(data["data"][i]["create_time"] == 0){
							html += '<td>无</td>';
						}else{
							html += '<td>' + timeStampTurnTime(data["data"][i]["create_time"])+ '</td>';
						}
						html += '<td><a href="ADMIN_MAIN/version/upgradeView?last_version_release='+ data['data'][i]['version_release'] + '">点击查看</a> ';
						html += '<a href="javascript:showFile('+ i +');">更新说明</a></td> ';
						html += '</tr>';
						$(".table-class tbody").append(html);
						var html1 = "";
						html1 += '<div class="modal fade hide" id="show_file'+ i +'" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:900px;margin-left:-450px;">';
						html1 += '<div class="modal-dialog">';
						html1 += '<div class="modal-content">';
						html1 += '<div class="modal-header">';
						html1 += '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>';
						html1 += '<h3>更新说明</h3>';
						html1 += '</div>';
						html1 += '<div class="modal-body">';
						html1 += '<div class="modal-infp-style" style="margin:auto;">';
						html1 += '<pre class="modal-tab file-table">';
						html1 += data["data"][i]["version_desc"];
						html1 += '</pre>';
						html1 += '</div>';
						html1 += '</div>';
						html1 += '<div class="modal-footer">';
						html1 += '<button class="btn-common" data-dismiss="modal">取消</button>';
						html1 += '</div>';
						html1 += '</div>';
						html1 += '</div>';
						html1 += '</div>';
						$("body").append(html1);
					}
				} else {
					var message = data.message;
					if(data["code"] == 0){
						message = "没有可升级的版本!";
					}
					var html = '<tr align="center"><td colspan="7">'+message+'</td></tr>';
					$(".table-class tbody").html(html);
				}
				//分页操作
				initPageData(Math.ceil(data['data'].length / 40),40,data['data'].length);
				$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
			}
		}
	});
}
function showFile(i){
	$("#show_file"+ i).modal("show");
}

</script>
{/block}